package com.manlost.web.common;

import java.text.SimpleDateFormat;
import java.util.Date;

public class FormateID {
	public static  Long generateID()
	{
		Date currentTime = new Date();
		String id=dateToStr(currentTime,"yyyyMMddHHmmssSSS")+genRandomNum(2);
		return Long.valueOf(id);
	}
	
	public static String genRandomNum(int length){
	    int index=0;
	    StringBuffer str = new StringBuffer("");
	    for(;index<length;index++){
	    	str.append((int)(Math.random()*10) );
	    }
	    return str.toString();
	 }
	
	public static String dateToStr(Date date, String format) {
		if (date == null)return "";
		SimpleDateFormat df =new SimpleDateFormat(format);
		return df.format(date);
	}
}
